package de.argh.codebook.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotEmpty;

public class Article {

  @NotNull
  private Long id;

  private String title;

  @NotEmpty
  private String body;

  private List<Article> comments;
  
  @NotNull
  private Coder author;

  @NotNull
  private Date created;

  private Date lastModified;

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public String getBody() {
    return body;
  }

  public void setBody(String body) {
    this.body = body;
  }

  public List<Article> getComments() {
    if (comments == null) {
      comments = new ArrayList<Article>();
    }
    return comments;
  }

  public void setComments(List<Article> comments) {
    this.comments = comments;
  }

  public Coder getAuthor() {
    return author;
  }

  public void setAuthor(Coder author) {
    this.author = author;
  }
  
  public Date getCreated() {
    return created;
  }

  public void setCreated(Date created) {
    this.created = created;
  }

  public Date getLastModified() {
    return lastModified;
  }

  public void setLastModified(Date lastModified) {
    if(this.created == null) {
      this.created = lastModified;
    }
    this.lastModified = lastModified;
  }

}
